<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.situ.web.entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		pageContext.setAttribute("age", 18);
		pageContext.setAttribute("gender", "男");
	%>
	<c:set var="age" value="10" ></c:set>
	<!-- 1、但条件判断 -->
	<c:if test="${age==10}">
		今年10岁了
	</c:if>
	<br/>
	<c:if test="${gender=='男'}">
		男
	</c:if>
	<c:if test="${gender=='女'}">
		女
	</c:if>
	<hr/>
	<!-- 2、多条件判断 -->
	<c:set var="score" value="97"></c:set>
	<c:choose>
		<c:when test="${score >= 90 && score <= 100}">
			优秀
		</c:when>
		<c:when test="${score >= 80 && score < 90}">
			良好
		</c:when>
		<c:when test="${score >= 70 && score < 80}">
			一般
		</c:when>
		<c:when test="${score >= 60 && score < 70}">
			及格
		</c:when>
		<c:otherwise>
			不及格
		</c:otherwise>
	</c:choose>
	<hr/>
	<!-- 3、集合遍历
		(1) 遍历List<String>
		(2) 遍历List<Student>
		(3) 遍历Map<String, String>
			Map<String, Student>
	 -->
	 <!-- step:默认是1，类似于for循环中i++, step=2 相当于i=i+2 -->
	 <c:forEach begin="0" end="5" var="i" step="2">
	 	${i}
	 </c:forEach>
	<br/>
	<%
		Student student1 = new Student(1, "张三1", 23, "男");
		Student student2 = new Student(2, "张三2", 24, "男");
		Student student3 = new Student(3, "张三3", 25, "男");
		List<Student> list = new ArrayList<Student>();
		list.add(student1);
		list.add(student2);
		list.add(student3);
		request.setAttribute("list", list);
	%>
	<c:forEach items="${list}" var="student">
		${student.name} -- ${student.age}
	</c:forEach>
	<%
		Map<String, String> map = new HashMap<String, String>();
		map.put("cn", "中国");
		map.put("us", "美国");
		request.setAttribute("map", map);
	%>
	<br/>
	<c:forEach items="${map}" var="entry">
		${entry.key} -- ${entry.value}
	</c:forEach>
	
	<%
		Student stu1 = new Student(1, "李四1", 23, "男");
		Student stu2 = new Student(2, "李四2", 24, "男");
		Student stu3 = new Student(3, "李四3", 25, "男");
		Map<String, Student> stuMap = new HashMap<String, Student>();
		stuMap.put("stu1", stu1);
		stuMap.put("stu2", stu2);
		stuMap.put("stu3", stu3);
		request.setAttribute("stuMap", stuMap);
	%>
	<br/>
	<c:forEach items="${stuMap}" var="entry">
		${entry.key} -- ${entry.value}<br/>
		${entry.key} -- ${entry.value.name}<br/>
	</c:forEach>
	
</body>
</html>